////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file   CollabRCBot\ArithmeticMeanTreeNode.h
///
/// @brief  Declares the CollabRC::Bot::AI::ArithmeticMeanTreeNode class
////////////////////////////////////////////////////////////////////////////////////////////////////

#pragma once
#include "OperationTreeNode.h"

namespace CollabRC
{
    namespace Bot
    {
        namespace AI
        {
            class ComputationalTreeNodeVisitor;

            /**
             * @brief Implementation of an OperationTreeNode which allows for computation
             * of an arithmetic mean. 
             *
             * For a weighted arithmetic mean, this node's branches can be 
             * combined with multiplication operations.
             * @version $Id$
             * @author Matthew P. Del Buono
             */
            class ArithmeticMeanTreeNode : public OperationTreeNode
            {
            private:
                class Factory : public OperationTreeNode::OperationTreeNodeFactory
                {
                public:
                    Factory();
                    ComputationalTreeNode* Instantiate(const ComputationalTreeNode& lhs, const ComputationalTreeNode &rhs) const;
                };

                static Factory factory;
            public:
                ArithmeticMeanTreeNode(const ComputationalTreeNode& lhs, const ComputationalTreeNode& rhs);
                ArithmeticMeanTreeNode(const OperationTreeNode& copy);
                virtual ~ArithmeticMeanTreeNode();
                virtual float PerformOperation(float lhs, float rhs) const;
                virtual ComputationalTreeNode* Clone() const;
                virtual void Accept(ComputationalTreeNodeVisitor& visitor);
            };

        }
    }
}
